//
//  TTFiltrateView.h
//  TaoTuo
//
//  Created by admin on 2019/8/20.
//  Copyright © 2019 admin. All rights reserved.
//

#import <UIKit/UIKit.h>
@class TTFiltrateView;

typedef void(^SelectedItemArrayBlock)(NSArray * _Nullable selectedArray);

typedef void(^SelectedItemArrayAndViewBlock)(TTFiltrateView * _Nullable filtrateView, NSArray * _Nullable selectedArray, NSInteger index);

NS_ASSUME_NONNULL_BEGIN

@interface TTFiltrateView : UIView

@property (nonatomic, strong) NSArray *dataArray;
@property (nonatomic, assign) BOOL canCancelSelect; //能否取消选中，对单选而言，默认YES

@property (nonatomic, strong) UIColor *normalBackgroundColor;
@property (nonatomic, strong) UIColor *selectedBackgroundColor;
@property (nonatomic, strong) UIColor *normalTitleColor;
@property (nonatomic, strong) UIColor *selectedTitleColor;
@property (nonatomic, strong) UIColor *boardColor;
@property (nonatomic, assign) CGFloat boardWidth;

- (instancetype)initWithFrame:(CGRect)frame allowsMultiple:(BOOL)allowsMultiple  selectedArrayBlock:(SelectedItemArrayBlock)selectedArrayBlock leftRightSpace:(CGFloat)leftRightSpace;

- (instancetype)initWithFrame:(CGRect)frame allowsMultiple:(BOOL)allowsMultiple  selectedArrayBlock:(SelectedItemArrayBlock)selectedArrayBlock leftRightSpace:(CGFloat)leftRightSpace cornerRadius:(CGFloat)cornerRadius;

///允许多选，但是至少要选中一个
- (instancetype)initWithFrame:(CGRect)frame allowsMultipleButAtLeastOne:(BOOL)allowsMultipleButAtLeastOne  selectedArrayBlock:(SelectedItemArrayBlock)selectedArrayBlock leftRightSpace:(CGFloat)leftRightSpace;

- (instancetype)initWithFrame:(CGRect)frame allowsMultiple:(BOOL)allowsMultiple  selectedItemArrayAndViewBlock:(SelectedItemArrayAndViewBlock)selectedArrayBlock;

// 设置固定的宽高
- (void)setFixWidthAndHeight:(CGSize)itemSize;

// 设置layout参数
- (void)setLayoutConfigWithMinimumLineSpacing:(CGFloat)minimumLineSpacing minimumInteritemSpacing:(CGFloat)minimumInteritemSpacing sectionInset:(UIEdgeInsets)sectionInset;

// 选中前三个(比较特殊转为裸石搜索页面写的)
- (void)selectWithIndex:(NSInteger)index;

///默认选中前几个
-(void)defaultSelectBeforeIndex:(NSInteger)index;

// 设置选中第一个
- (void)setSelectedFirstItem;

// 选中第一个不回调
- (void)setSelectedFirstItemAndNoBlock;

/// 设置选中某一个
- (void)setSelectedItemWithIndex:(NSInteger)index;



// 重置
- (void)resetView;

///滚动到第几个item
- (void)scrollToIndex:(NSInteger)index;

/// 让某个item居中
- (void)scrollToCenterWithIndex:(NSInteger)index;

///设置偏移量
- (void)scrollToOffsetX:(CGFloat)offsetX;

@end

NS_ASSUME_NONNULL_END
